package chapter04;

public class Test01_extends {
    public static void main(String[] args) {
        Dog d = new Dog("大黄",50,"黄色");
        System.out.println(d.getName());
        System.out.println(d.getAge());
        System.out.println(d.getColor());
        d.shout();
    }
}
class Animal{
    private String name;
    private int age;
    final public int id = 110;//常量
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public void shout(){
        System.out.println("发出声音");
    }
}
class Dog extends Animal{
    private String color;
    public Dog(String name, int age,String color) {
        super(name, age);//调用父类的构造函数
        this.color = color;
    }
    public String getColor() {
        return color;
    }
    public void setColor(String color) {
        this.color = color;
    }
    public void shout(){
        //调用父类的方法
        super.shout();
        System.out.println("汪汪");
    }
}
